//
//  WdxyybVC+UI.swift
//  Auscultation
//
//  Created by 来 on 2020/12/22.
//

import Foundation

extension WdxyybVC {
    
    func initUI() {
        let top_view = UIImageView.init(image: #imageLiteral(resourceName: "beijing2@1.5x"))
        top_view.isUserInteractionEnabled = true
        view.addSubview(top_view)
        top_view.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(UIDevice.lgf_NavBarH() + 80)
        }
        self.navTitle = "我的心音样本"
        self.rightText = "+ 新增 "
        self.lgf_NavigationBar.style.lgf_RightBtnTitleColor = UIColor.white
        self.lgf_NavigationBar.style.lgf_TitleColor = UIColor.white
        self.lgf_NavigationBar.lgf_line?.isHidden = true
        self.lgf_NavigationBar.lgf_Reload()
        
        // 搜索 bar
        let search_bar = UIView.init()
        search_bar.backgroundColor = UIColor.white.withAlphaComponent(0.32)
        search_bar.layer.cornerRadius = 4
        top_view.addSubview(search_bar)
        search_bar.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(UIDevice.lgf_NavBarH() + 20)
            make.left.equalToSuperview().offset(20)
            make.right.equalToSuperview().offset(-60)
            make.height.equalTo(40)
        }
        let search_image = UIImageView.init(image: #imageLiteral(resourceName: "sousuo@1.5x"))
        search_bar.addSubview(search_image)
        search_image.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(12)
            make.width.height.equalTo(16)
        }
        let search_text = UITextField.init()
        search_text.delegate = self
        search_text.attributedPlaceholder = NSAttributedString.init(string:"样本名称", attributes: [NSAttributedString.Key.foregroundColor:UIColor.white])
        search_text.textColor = UIColor.white
        search_text.tintColor = UIColor.white
        search_text.font = UIFont.systemFont(ofSize: 12)
        search_bar.addSubview(search_text)
        search_text.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalTo(search_image.snp.right).offset(12)
            make.right.equalToSuperview()
            make.height.equalToSuperview()
        }
        
        let sx = UILabel.init()
        sx.text = "筛选"
        sx.font = UIFont.systemFont(ofSize: 14)
        sx.textAlignment = .center
        sx.textColor = UIColor.white
        sx.isUserInteractionEnabled = true
        sx.lgf_AddTap(target: self, action: #selector(WdxyybVC.s_sx))
        top_view.addSubview(sx)
        sx.snp.makeConstraints { (make) in
            make.centerY.equalTo(search_bar)
            make.left.equalTo(search_bar.snp.right)
            make.right.equalToSuperview()
            make.height.equalTo(50)
        }
        
        collectionView = UICollectionView.init(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout.lgf_Layout(0, 0, 8, 0, 0, 0))
        collectionView.backgroundColor = UIColor.init(lgf_HexString: "F1F2F4")
        collectionView.lgf_Register(cellType: YbCell.self)
        collectionView.delegate = self
        collectionView.dataSource = self
        view.addSubview(collectionView)
        collectionView.snp.makeConstraints { (make) in
            make.top.equalTo(top_view.snp.bottom)
            make.centerX.equalToSuperview()
            make.width.equalToSuperview()
            make.bottom.equalToSuperview()
        }
    }
    
}
